home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4230 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.2 KB

  1. Path: wallias.eda.com!news
  2. From: risk@eda.com
  3. Newsgroups: comp.lang.c
  4. Subject: Question: Linking a Turbo assembler .OBJ with a C .obj in Borland v4.0
  5. Date: 2 Feb 1996 19:22:27 GMT
  6. Organization: EDA Instruments Inc, Toronto, Canada
  7. Message-ID: <4eto9j$893@wallias.eda.com>
  8. NNTP-Posting-Host: risk.eda.com
  9. Mime-Version: 1.0
  10. Content-Type: multipart/mixed;
  11.     boundary="-------------------------------66331716921094"
  12. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  13.  
  14. This is a multi-part message in MIME format.
  15.  
  16. ---------------------------------66331716921094
  17. Content-Transfer-Encoding: 7bit
  18. Content-Type: text/plain; charset=us-ascii
  19.  
  20. Question:  When I try to link the obj's in the project, I get a linker 
  21. (TLINK) warning message saying
  22.  
  23. "Linker Error: Undefined symbol _fetch in module MAIN.C"
  24.  
  25. I've tried using various methods of prototyping (including 'extern "c"' 
  26. which didn't work -- I'm not using any C++ compiler functionality).
  27.  
  28. The ASM file is one of two nodes for the executable in the project IDE.
  29.  
  30. What do I have to do to get it to link?
  31.  
  32. ---------------------------------66331716921094
  33. Content-Transfer-Encoding: 7bit
  34. Content-Type: text/plain
  35.  
  36. ; Medium model C - callable assembler function to crc data from the
  37. ; the printer port.
  38. ;
  39. ; Function prototype:
  40. ;    extern unsigned short int Fetch(char * near,
  41. ;                                    char * near );
  42. ;
  43. ; Input:
  44. ;   char * near ; pointer to the memory buffer <16kbytes
  45. ;
  46. ; Returns:
  47. ;   CRC value of data calculated in and returned in ax
  48. ;
  49.          .MODEL  medium                  ;
  50.          .CODE                           ;
  51.          PUBLIC  _crc                  ;
  52. _crc   PROC                            ;
  53.          push    bp                      ;stack pointer
  54.          mov     bp,sp                   ;index stuff from bp instead of sp
  55.          push    si                      ;stack data index
  56.          push    di                      ;stack CRC table index
  57.          push    ds                      ;stack data segment pointer
  58.          lds     si,[bp+4]               ;load the memory pointer into ds:si
  59.          les     bx,[bp+6]               ;load the CRC table pointer into es:bx
  60.                                          ;
  61.          ;Do a CRC on the data passed.   ;
  62.          ;ax contains the CRC value      ;
  63.          mov     cx,4000h                ;crc 16 kbytes of memory
  64.          xor     ax,ax                   ;clear ax  (start crc at 0)
  65. crc_loop:                                ;
  66.          mov     bl,ds:[si]              ;read next byte of memory
  67.          xor     bx,ax                   ;caculate CRC look up value
  68.          and     bx,00ffh                ;ensure lookup value <255
  69.          shl     bx,01h                  ;multiply by two for word size
  70.          mov     bx,es:[bx]              ;read the table value
  71.          shr     ax,08h                  ;shift crc value down
  72.          xor     ax,bx                   ;calculate new crc value
  73.          loop    crc_loop                ;
  74.          pop     ds                      ;
  75.          pop     di                      ;
  76.          pop     si                      ;
  77.          pop     bp                      ;
  78.          ret                             ;
  79. _crc   ENDP                            ;
  80.          END                             ;
  81.  
  82.